<template>
  <div>
    <el-dialog title="删除角色" :visible.sync="buttontype" @close="fun(tname)">
      <div style="text-align: center">
        你确定要删除
        <span style="color: #0aa1ed">{{ tablerow.title }}</span>
        吗？
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="getdelete">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { http, article } from "../../api/api";
export default {
  props: ["type", "fun", "tname", "tablerow"],
  data() {
    return {
      buttontype: this.type, //模态框状态
    };
  },
  methods: {
    getdelete() {
      this.$http
        .delete(http + article, {
          params: {
            id: this.tablerow.id,
          },
        })
        .then(
          (data) => {
            console.log(data.data);
            if (data.data.msg == "成功") {
              this.buttontype = false;
              this.$message.success("删除成功");
            } else {
              this.$message.error(data.data.message);
            }
          },
          (err) => {
            this.$message.error(`删除${err.data.message},请确认格式是否正确`);
          }
        );
    },
  },
  watch: {
    type() {
      this.buttontype = this.type;
    },
  },
};
</script>

<style>
</style>